function inputAssetBrand(){		
	var status;
	if (Ext.getCmp('activeBrand').getValue() == true)
		status = 'true';
	else 
		status = 'false';
		
	var abId = Ext.getCmp('abIdBrand').getValue();
	var scId = Ext.getCmp('scIdBrand').getValue();
	var brand = Ext.getCmp('brand').getValue();
		
	if(Ext.getCmp('categoryBrand').getValue() == null || Ext.getCmp('categoryBrand').getValue() == "") {
		Ext.MessageBox.show({
		 	title: 'WARNING!',
	        msg: 'Field Category Required',
	        icon: Ext.Msg.WARNING
	    });
	} else if(Ext.getCmp('subCategoryBrand').getValue() == null || Ext.getCmp('subCategoryBrand').getValue() == "") {
		Ext.MessageBox.show({
		 	title: 'WARNING!',
	        msg: 'Field SubCategory Required',
	        icon: Ext.Msg.WARNING
	    });
	} else if(Ext.getCmp('brand').getValue() == null || Ext.getCmp('brand').getValue() == "") {
		Ext.MessageBox.show({
		 	title: 'WARNING!',
	        msg: 'Field Brand Required',
	        icon: Ext.Msg.WARNING
	    });
	} else {
		var data = {AB_ID:abId, SC_ID: scId, BRAND:brand, ACTIVE:status, USER:""};
		
		if (Ext.getCmp('ButtonInsertBrand').getText()=="Add Brand"){
			 var url  = './Services/DataMaster/AssetBrand/Add';
			 PostData(data,url,"Insert");
		}else{
			 var url  = './Services/DataMaster/AssetBrand/Update';
			 PostData(data,url,"Update");
		}                                                   
		
		Ext.getCmp('ButtonInsertBrand').setText("Add Brand");
		emptyAssetBrand();                                                             
		Ext.getStore('Administration.AssetBrand').load();
		Ext.getStore('AssetDataMaster.Brand').load();

	}

}

function deleteAssetBrand(){
	var rec = Ext.getCmp('tableAssetBrand').getSelectionModel().getSelection();
	if (rec.length>0){
		  Ext.MessageBox.confirm('Delete', 'Are you sure ?', function(btn) {
		        if (btn === 'yes') {
		        	 for (var i = 0; i<rec.length ; i++){
		     	    	var id = rec[i].get('AB_ID');
		     	    	var data = {AB_ID: id};
		     	    	var url  = './Services/DataMaster/AssetBrand/Delete';
		     	    	PostData(data,url,"Delete");
		     	    }
		        	refreshAssetBrand();		        
		        }
		    });
	}else{
    	Ext.MessageBox.show({
		 	title: 'WARNING!',
	        msg: 'No Data Selected',
	        icon: Ext.Msg.WARNING
	    });	
    }
}

function getValueAssetBrand(){
	Ext.getCmp("categoryBrand").setDisabled(true);
	Ext.getCmp("subCategoryBrand").setDisabled(true);
	Ext.getCmp("scIdBrand").setDisabled(true);
	Ext.getCmp("abIdBrand").setDisabled(true);
	Ext.getCmp("ButtonAddType").setDisabled(true);
	Ext.getCmp("ButtonClearBrand").setDisabled(true);
    Ext.getCmp('scIdBrand').setValue(Ext.getCmp('ScId').getValue());
    Ext.getCmp('categoryBrand').setValue(Ext.getCmp('Category').getValue());
    Ext.getCmp('subCategoryBrand').setValue(Ext.getCmp('SubCategory').getValue());
    emptyAssetBrand();
    searchAssetBrand();
}

function getValueGridBrand(record){
	Ext.getCmp("ButtonAddType").setDisabled(false);
	Ext.getCmp("ButtonClearBrand").setDisabled(false);
	Ext.getCmp('ButtonInsertBrand').setText('Update Brand');
    Ext.getCmp('abIdBrand').setValue(record.get('AB_ID'));
    Ext.getCmp('brand').setValue(record.get('BRAND'));
    if (record.get('ACTIVE')=="true"){
    	Ext.getCmp('activeBrand').setValue(true);
    }else{
    	Ext.getCmp('inactiveBrand').setValue(true);
    }  
}

function emptyAssetBrand(){
	Ext.getCmp('ButtonInsertBrand').setText('Add Brand');
	Ext.getCmp('ButtonAddType').setDisabled(true);
	Ext.getCmp('abIdBrand').setValue("");
	Ext.getCmp('brand').setValue("");
	Ext.getCmp('activeBrand').setValue(true);	
}

function searchAssetBrand(){
	var subCategory = Ext.getCmp("subCategoryBrand").getValue();
	var keyword = Ext.getCmp("keywordBrand").getValue();
	Ext.getStore('Administration.AssetBrand').getProxy().url = "./Services/DataMaster/AssetBrand/List?SUB_CATEGORY="+subCategory+"&keyword="+keyword+"";
	Ext.getStore('Administration.AssetBrand').load();	
}

function refreshAssetBrand(){
	Ext.getCmp('keywordBrand').setValue("");
	searchAssetBrand();
}
